package com.edu.mapper;

import com.edu.entity.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.util.List;

public interface BookMapper {
    @Select("SELECT * FROM book WHERE bookId = #{bookId}")
    Book selectBookById(int bookId);

    @Select("SELECT * FROM book")
    List<Book> selectAllBooks();

    @Delete("DELETE FROM book WHERE bookId = #{bookId}")
    int deleteBook(int bookId);

    @Insert("INSERT INTO book (bookName,bookWriter,bookType) VALUES (#{bookName}, #{bookWriter}, #{bookType})")
    int insertBook(Book book);

    @Update("UPDATE book SET  bookName=#{bookName}, bookWriter=#{bookWriter},bookType=#{bookType} WHERE bookId = #{bookId}")
    int updateBook(Book book);

}
